package com.sundaying.gooway.action;

import java.util.List;
import java.util.Map;

import com.opensymphony.xwork2.ActionSupport;
import com.sundaying.gooway.interceptor.Authority;
import com.sundaying.gooway.model.UrlClass;
import com.sundaying.gooway.service.UrlClassService;

public class UrlClassAction extends ActionSupport {
	private UrlClassService urlClassService = new UrlClassService();
	private List<UrlClass> urlClassList;
	private UrlClass urlClass;
	private String classID;
	private List<Map<String, Object>> urlClassTree;

	public List<Map<String, Object>> getUrlClassTree() {
		return urlClassTree;
	}
	public void setUrlClassTree(List<Map<String, Object>> urlClassTree) {
		this.urlClassTree = urlClassTree;
	}
	
	public String getClassID() {
		return classID;
	}
	public void setClassID(String classID) {
		this.classID = classID;
	}
	public UrlClass getUrlClass() {
		return urlClass;
	}
	public void setUrlClass(UrlClass urlClass) {
		this.urlClass = urlClass;
	}
	public List<UrlClass> getUrlClassList() {
		return urlClassList;
	}
	public void setUrlClassList(List<UrlClass> urlClassList) {
		this.urlClassList = urlClassList;
	}

	@Authority(actionName="UrlClassAction", privilege="list")
	public String list(){
		urlClassList = urlClassService.list();
		return this.SUCCESS;
	}
	
	public String tree(){
		urlClassTree = urlClassService.tree(0);
		return this.SUCCESS;
	}
	
	@Authority(actionName="UrlClassAction", privilege="add")
	public String add(){
		urlClassService.add(urlClass);
		return this.SUCCESS;
	}
	
	public String loadById(){
		urlClassList = urlClassService.list();
		urlClass = urlClassService.loadByID(classID);
		return this.SUCCESS;
	}
	
	public String update(){
		urlClassService.update(urlClass);
		return this.SUCCESS;
	}
	
	public String delete(){
		urlClassService.delete(classID);
		return this.SUCCESS;
	}
}
